package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 使用流连接完成PW的创建
 */
public class PWDemo02 {
    public static void main(String[] args) throws FileNotFoundException {
          /*
            PrintWriter->BufferedWriter->OutputStreamWriter->FileOutputStream
            PW:负责按行写出字符串
            BW:块写文本数据加速(内部有一个默认8192长度的字符数组)
            OSW:将写出的字符转字节
            FOS:将字节写入到文件中
         */
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw);

        pw.println("您好啊");
        pw.println("hello");
        pw.close();
    }

}
